<script>
	import {
		requestData
	} from './utils/http';
	export default {
		globalData: {
			text: '全局数据-在app.vue中定义的'
		},
		onLaunch: function() {
			// 打开调试
			uni.setEnableDebug({
				enableDebug: true
			})
		},
		onShow: function() {
			let user_id = uni.getStorageSync('user_id')
			if (!user_id) {
				uni.login({
					success: (res) => {
						requestData('/wxaccess/mp/user/login', {
								wxlogin_code: res.code,
							})
							.then((res) => {
								uni.removeStorageSync('open_id')
								uni.removeStorageSync('access_token')
								uni.removeStorageSync('user_id')
								//uni.removeStorageSync('mobile_binded')
								uni.removeStorageSync('mobile')
								uni.setStorageSync('open_id', res?.data?.datas?.open_id || '')
								uni.setStorageSync('user_id', res?.data?.datas?.user_id || '')
								uni.setStorageSync(
									'access_token',
									res?.data?.datas?.access_token || ''
								)
								// uni.setStorageSync(
								// 	'mobile_binded',
								// 	res?.data?.datas?.mobile_binded || 0
								// )
								uni.setStorageSync('mobile', res?.data?.datas.mobile || '')
							})
							.catch((err) => {
								console.log(err)
							})
					},
					fail: (err) => {
						console.log(err)
					},
				})
			}
		},
		onHide: function() {
			//console.log('App Hide')
		}
	}
</script>
<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "@/uni_modules/uview-ui/index.scss";

	page {
		font-size: 32rpx !important;
	}
</style>